import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const homeOption = {
  //开启命名空间
  namespaced: true,
  state: {
    count: 0
  },
  getters: {
    mul(state) {
      return state.count * 2
    }
  },
  mutations: {
    jiaM(state, value) {
      console.log(value)
      state.count += value
    },
    jianM(state, value) {
      state.count -= value
    }
  },
  actions: {
    jiaA(content, value) {
      content.commit('jiaM', value)
    },
    jianA(content, value) {
      content.commit('jianM', value)
    }
  },
  modules: {}
}

const aboutOption = {
  namespaced: true,
  state: {
    name: 'zhangsan'
  },
  getters: {
    upperCaseName(state) {
      return state.name.toUpperCase()
    }
  },
  mutations: {
    editNameM(state, value) {
      state.name = value
    }
  },
  actions: {
    editNameA(content, value) {
      content.commit('editNameM', value)
    }
  },
  modules: {}
}

export default new Vuex.Store({
  modules: {
    // homeOption: homeOption,
    // aboutOption: aboutOption
    homeOption,
    aboutOption
  }
})
